package com.shuoyue.ycgk.ui.recruitment.newsinfo;

import android.text.Html;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseViewHolder;
import com.shuoyue.ycgk.R;
import com.shuoyue.ycgk.base.baseadapter.AppBaseQuickAdapter;
import com.shuoyue.ycgk.entity.RecruitmentItem;

import java.util.List;

public class NoticeAdapter extends AppBaseQuickAdapter<RecruitmentItem> {
    boolean isShowDelete = false;

    public NoticeAdapter(@Nullable List<RecruitmentItem> data, boolean isShowDelete) {
        super(R.layout.item_recuri, data);
        this.isShowDelete = isShowDelete;
    }

    public NoticeAdapter(@Nullable List<RecruitmentItem> data) {
        this(data, false);
    }


    @Override
    protected void convert(BaseViewHolder helper, RecruitmentItem item) {
        helper.addOnClickListener(R.id.lay_all);
        helper.addOnClickListener(R.id.delete);

        helper.setText(R.id.title, "                   " + item.getTitle());
        helper.setGone(R.id.hot, item.getIsIndex() == 1);
        helper.setGone(R.id.delete, isShowDelete);

//        helper.setText(R.id.info, "招" + item.getEnrollment() + "人/"
//        + item.getPostNum() + "个职位");//招10人/15个职位
        helper.setText(R.id.info, item.getAreaName());
        helper.setText(R.id.info1, " . "
                + item.getCreateTime());
//        helper.setText(R.id.info2, Html.fromHtml("招考职位<font color='#2196F3'>" + item.getPostNum() + "</font>个"));//招10人/15个职位
//        helper.setText(R.id.info2, Html.fromHtml("招考职位<font color='#2196F3'>" + item.getPostNum() + "</font>个"));
        helper.setText(R.id.info2, Html.fromHtml("招<font color='#2196F3'>" + item.getEnrollment() + "</font>人/<font color='#2196F3'>"
                + item.getPostNum() + "</font>个职位"));

//        helper.setText(R.id.info2, "招" + item.getEnrollment() + "人/"
//                + item.getPostNum() + "个职位");

        if (item.getStatus() == 1) {
            helper.setText(R.id.tag, "即将报名");
            helper.setBackgroundRes(R.id.tag, R.mipmap.tag_in_blue);
        } else if (item.getStatus() == 0) {
            helper.setText(R.id.tag, "正在报名");
            helper.setBackgroundRes(R.id.tag, R.mipmap.tag_in_orange);
        } else {
            helper.setText(R.id.tag, "报名结束");
            helper.setBackgroundRes(R.id.tag, R.mipmap.tag_in_gray);

        }
    }


}
